package com.vca.admin.filter;


import com.vca.common.constants.Constants;
import com.vca.common.utils.SpringUtil;
import com.vca.service.service.SystemAttachmentService;

/**
 * response路径处理
 */
public class ResponseRouter {

    public String filter(String data, String path) {
        boolean result = un().contains(path);
        if (result) {
            return data;
        }

        if (!path.contains("api/admin/") && !path.contains("api/front/")) {
            return data;
        }

//        if (path.contains("api/admin/store/order/send")){
//            return data;
//        }

        //根据需要处理返回值
        if (data.contains(Constants.UPLOAD_TYPE_IMAGE + "/") && !data.contains("data:image/png;base64")) {
            if (!data.contains(Constants.UPLOAD_TYPE_FILE + "/" + Constants.UPLOAD_MODEL_PATH_EXCEL)) {
                data = SpringUtil.getBean(SystemAttachmentService.class).prefixImage(data);
            }
        }

        if (data.contains(Constants.UPLOAD_TYPE_FILE+"/")) {
            if (data.contains(Constants.UPLOAD_TYPE_FILE + "/" + Constants.UPLOAD_MODEL_PATH_EXCEL)) {
                data = SpringUtil.getBean(SystemAttachmentService.class).prefixFile(data);
            } else if (data.contains("localfile")) {
                data = data;
            } else {
                data = SpringUtil.getBean(SystemAttachmentService.class).prefixFile(data);
            }
        }
        return data;
    }

    public static String un() {
        return "";
    }
}
